package com.bw.house.controller;


import com.bw.house.common.ResponseResult;
import com.bw.house.entity.TbHouse;
import com.bw.house.entity.TbUser;
import com.bw.house.service.ITbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 邢晋宁
 * @since 2020-09-04
 */
@RestController
@RequestMapping("user")
public class TbUserController {

    @Autowired
    private ITbUserService userService;

    /**
     * @Description: 用户登录
     * @Author: 李闯
     * @Date: 2020/9/5 8:47
     * @param user:
     * @param response:
     * @return: com.bw.house.common.ResponseResult
     **/
    @PostMapping("login")
    public ResponseResult login(@RequestBody TbUser user, HttpServletResponse response){

        return  userService.login(user,response);
    }

    /**
     * @Description: 用户列表展示
     * @Author: 王文佳
     * @Date: 2020/9/5 8:48
     * @param currentPage:
     * @param pageSize:
     * @param user:
     * @return: com.bw.house.common.ResponseResult
     **/
    @PostMapping("/list/{currentPage}/{pageSize}")
    public ResponseResult list(@PathVariable("currentPage")int currentPage,
                               @PathVariable("pageSize")int pageSize,
                               @RequestBody TbUser user){

        return userService.listAll(currentPage,pageSize,user);
    }

    /**
     * @Description: 注册房东
     * @Author: 王文佳
     * @Date: 2020/9/5 14:43
     * @param user:
     * @return: com.bw.house.common.ResponseResult
     **/
    @PostMapping("/saveUser")
    public ResponseResult saveUser(@RequestBody TbUser user){

        return userService.saveUser(user);
    }
}
